package com.whu.service.impl;

import com.whu.dao.CommodityDao;
import com.whu.domain.Commodity;
import com.whu.service.CommodityServiceInterface;


import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CommodityService implements CommodityServiceInterface {

    @Resource
    private CommodityDao commodityDao;


    @Override
    public boolean add(Commodity commodity) {
        int flag = commodityDao.add(commodity);
        return (flag > 0);
    }

    @Override
    public boolean delete(Integer id) {
        int flag = commodityDao.delete(id);
        return (flag > 0);
    }

    @Override
    public boolean update(Commodity commodity) {
        int flag = commodityDao.update(commodity);
        return (flag > 0);
    }

    @Override
    public List<Commodity> getById(Integer id) {
        return commodityDao.getById(id);
    }

    @Override
    public List<Commodity> getByName(String name) {
        return commodityDao.getByName(name);
    }

    @Override
    public List<Commodity> getAll() {
        return commodityDao.getAll();
    }
}
